package com.hspedu.collection_;

import java.util.Arrays;

/**
 * @author 谷其昊
 * @version 1.0
 * @date 2022/2/6
 * @time 22:57
 */
public class TestDilatation {
    public static void main(String[] args) {
        //现在是已经明确需要扩容了
        A2 a2 = new A2();
        int oldCapacity = a2.elementData.length;
        int newCapacity = oldCapacity + (oldCapacity >> 1);
        if (newCapacity == 0){
            newCapacity = 10;
        }
        a2.elementData = Arrays.copyOf(a2.elementData,newCapacity);
    }
}

class A2{
    transient Object[] elementData = {};
}